/**
 * futures : masterlink.futures.vo.RealReposotory.java
 */
package masterlink.futures.vo;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import baytony.util.Util;

/**
 * TODO Write the description
 *
 * @author : tonyyang
 * Create date : 2011/11/8
 * @version 1.0.0	
 */
public class RealReposotory implements Serializable{

	private static final long serialVersionUID = 7655140816367749465L;
	private final Account account;
	private final List<FutpabReal> list=new ArrayList<FutpabReal>();
	private final List<FutmatDetail> list2=new ArrayList<FutmatDetail>();
	/**
	 * @param account
	 * @param futpab
	 */
	public RealReposotory(Account account) {
		this.account = account;
	}
	/**
	 * @return the account
	 */
	public Account getAccount() {
		return account;
	}
	/**
	 * @return the list
	 */
	public List<FutpabReal> getList() {
		return list;
	}
	public List<FutmatDetail> getList2() {
		return list2;
	}	
	public void addFutpabReal(FutpabReal futpabReal){
		if(futpabReal!=null){
			this.list.add(futpabReal);
		}
	}
	public void addFutmatDetail(FutmatDetail futmatDetail){
		if(futmatDetail!=null){
			this.list2.add(futmatDetail);
		}
	}	
	public Long getQuantity(){
		if(!Util.isEmptyList(list)){
			long res=0l;
			for(FutpabReal f:list){
				res+=Math.abs(f.getQuantity());
			}
			return res;
		}
		return 0l;
	}
	public Long getQuantity2(){
		if(!Util.isEmptyList(list2)){
			long res=0l;
			for(FutmatDetail f:list2){
				res+=Math.abs(f.getQuantity());
			}
			return res;
		}
		return 0l;
	}
	/* (non-Javadoc)
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString() {
		StringBuilder builder = new StringBuilder();
		builder.append("RealReposotory [account=");
		builder.append(account);
		builder.append(", list=");
		builder.append(list.size());
		builder.append("]");
		return builder.toString();
	}
	
	/* (non-Javadoc)
	 * @see java.lang.Object#hashCode()
	 */
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((account == null) ? 0 : account.hashCode());
		return result;
	}
	/* (non-Javadoc)
	 * @see java.lang.Object#equals(java.lang.Object)
	 */
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (!(obj instanceof RealReposotory))
			return false;
		RealReposotory other = (RealReposotory) obj;
		if (account == null) {
			if (other.account != null)
				return false;
		} else if (!account.equals(other.account))
			return false;
		return true;
	}
	
}
